<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/icon.css"/>">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/yzr_style.css"/>">

<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<title>采购管理</title>
</head>
<body>
<%-- <script src="<c:url value="/js/jquery-migrate-1.1.0.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery.jqprint-0.3.js"/>"></script> --%>
<style>
	* {
		font-size: 12px;
	}
</style>


<!-- 添加 -->
<script type="text/javascript">
	var editIndexYzr_order = undefined;
	
	//添加行
	function appendYzr_order(){
		if(endEditingYzr_order()){
			//orderDetMedName,purchDetMedId,orderDetBatchnumber,purchDetGuige,purchDetUnit,orderDetPrice,purchDetNumber,
			//orderDetMoney,supId
			$('#yzr-purchorder-dg').datagrid('appendRow',{'orderDetMedName': [], 
									'purchDetMedId': [],'orderDetBatchnumber': [],'purchDetGuige': [],
									'purchDetUnit': [],'orderDetPrice': [],'purchDetNumber': [],
									'orderDetMoney': [],'supId': []});
			
			editIndexYzr_order = $('#yzr-purchorder-dg').datagrid('getRows').length-1;//返回当前页的行
			
			//选中一行，开始对一行进行编辑
			$('#yzr-purchorder-dg').datagrid('selectRow',editIndexYzr_order)
							   .datagrid('beginEdit',editIndexYzr_order);
						
		}
		
	}
	
	
	
	//删除行
	function removeitYzr_order(){
		if(editIndexYzr_order == undefined){return}
		//取消对一行的编辑，删除
		$('#yzr-purchorder-dg').datagrid('cancelEdit',editIndexYzr_order)
		   .datagrid('deleteRow',editIndexYzr_order);
	}
	
	//应用
	function acceptYzr_order(){
		if(endEditingYzr_order()){
			endEditingYzr_order();
		}
	}
	
	//撤销
	function rejectYzr_order(){
		//回滚自从创建以来或最后一次调用 acceptChanges 以来所有更改的数据。
		$('#yzr-purchorder-dg').datagrid('rejectChanges');
		editIndexYzr_order = undefined;
	}
	
	//获取数据
	function getChangesYzr_order(){
		//获取最后一次提交以来更改的行
		var rows = $('#yzr-purchorder-dg').datagrid('getChanges');
		alert(rows.length+' rows are changed!');
	}
	
	
	//结束正在编辑的行
	function endEditingYzr_order(){
		
		if (editIndexYzr_order == undefined){return true}
		
		//验证指定的行，有效时返回 true。
		if ($('#yzr-purchorder-dg').datagrid('validateRow', editIndexYzr_order)){
			
			var ed = $('#yzr-purchorder-dg').datagrid('getEditor', {index:editIndexYzr_order,field:'purchDetMedId'});					
			var medName = $(ed.target).combogrid('getText');			
			$('#yzr-purchorder-dg').datagrid('getRows')[editIndexYzr_order]['medName'] = medName;
			
			
			var ed2 = $('#yzr-purchorder-dg').datagrid('getEditor', {index:editIndexYzr_order,field:'supId'});					
			var supName = $(ed2.target).combogrid('getText');			
			$('#yzr-purchorder-dg').datagrid('getRows')[editIndexYzr_order]['supName'] = supName;
			
			
			$('#yzr-purchorder-dg').datagrid('endEdit', editIndexYzr_order);		
			editIndexYzr_order = undefined;
			return true;
		} else {
			return false;
		}
	}
	
	//事件：单击单元格的事件
	function onClickCellYzr_order(index, field){
		if (editIndexYzr_order != index){
			if (endEditingYzr_order()){
				
				$('#yzr-purchorder-dg').datagrid('selectRow', index).datagrid('beginEdit', index);
				
				var ed = $('#yzr-purchorder-dg').datagrid('getEditor', {index:index,field:field});
				
				if (ed){
					($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus();
				}
				editIndexYzr_order = index;
			} else {
				setTimeout(function(){
					$('#yzr-purchorder-dg').datagrid('selectRow', editIndexYzr_order);
				},0);
			}
		}
	}

	
	//结束编辑，同步数据
	function onEndEditYzr_order(index, row){	
		
		var ed = $(this).datagrid('getEditor', {
			index: index,
			field: 'purchDetMedId'
		});	
		row['orderDetMedName'] = $(ed.target).combogrid('getText');
		
		//自动算出金额
		var yzr_price = $(this).datagrid('getEditor', {
			index: index,
			field: 'orderDetPrice'
		});				
		var yzr_number = $(this).datagrid('getEditor', {
			index: index,
			field: 'purchDetNumber'
		});	
		row['orderDetMoney'] = $(yzr_price.target).textbox('getValue')*$(yzr_number.target).textbox('getValue');
	}
	
	//提交采购计划
	function savePlanYzr_order(){
		var rows = $('#yzr-purchorder-dg').datagrid('getRows');
		console.log(JSON.stringify(rows));		
		
		for(var i = 0; i < rows.length; i ++){
			//orderDetMedName,purchDetMedId,orderDetBatchnumber,purchDetGuige,purchDetUnit,orderDetPrice,purchDetNumber,orderDetMoney,supId
			generateHiddenYzr_order(rows[i], "orderDetMedName", i);
			generateHiddenYzr_order(rows[i], "purchDetMedId", i);
			generateHiddenYzr_order(rows[i], "orderDetBatchnumber", i);
			generateHiddenYzr_order(rows[i], "purchDetGuige", i);
			generateHiddenYzr_order(rows[i], "purchDetUnit", i);
			generateHiddenYzr_order(rows[i], "orderDetPrice", i);
			generateHiddenYzr_order(rows[i], "purchDetNumber", i);
			generateHiddenYzr_order(rows[i], "orderDetMoney", i);
			generateHiddenYzr_order(rows[i], "supId", i);
		}
		
		var ff_plan = $("#yzr_purchorder_form");
		
		ff_plan.form("submit", {
			success: function(v){
				$.messager.alert('提示', "提交成功");
				$(":hidden[x='y']").remove();			
				//重新加载采购计划
				$("#yzr-purch-cg").combogrid({
					 url:'queryStateAndAutState',
				}); 
				$('#yzr-purchorder-dg').datagrid('loadData',{total:0,rows:[]});				
				$('#yzr_purchorder_form').form("clear");				
				$('#yzr-purchorder-window').window('close');
				$("#tb-purchorder").datagrid("reload");
				
			}
		});
	}
	
	function generateHiddenYzr_order(row, name, i){
		var ff_plan = $("#yzr_purchorder_form");
		$("<input type='hidden' x='y'>")
			.attr("name", "orderDets[" + i + '].' + name)
			.val(row[name])
			.appendTo(ff_plan);
	}
	
	

</script>

<!-- 打印 -->
<script type="text/javascript">

	$(function(){
		
		//获取当前登录用户的id
		var  orderCdr_staffId = $("#tontyiStaffId").html();
		
		//验证批号
		$.extend($.fn.validatebox.defaults.rules,{ 
	         pihao:{ 
	             validator: function (value) {   
	                    return /^(H|Z|B|S|T|F|J)\d{8}$/i.test(value); 
	                },   
	                message: '批号格式不正确'  
	         }
	     });    
	     
	     
	     
		//采购计划单号改变时触发——添加
		$("#yzr-purch-cg").combogrid({onChange: function(newValue, oldValue){
			var planId = $("#yzr-purch-cg").combogrid("getValue");
			//$.messager.alert('提示', planId);			
			$("#yzr-purchorder-dg").datagrid({
	    		url: 'queryAllPurchDet2', 
	    		queryParams:{					
					purchId: planId
				}
	    	});
		}});
		

		//点击添加按钮打开窗口——添加
		$("#yzr-purchorder-add").linkbutton({onClick: function(){
			$('#yzr_purchorder_form').form("clear");
			rejectYzr_order();
			$(":hidden[x='y']").remove();			
			$('#yzr-purchorder-window').window("open");
			$("#yzrr-purchoder-cgr").combogrid("setValue",orderCdr_staffId);
			
		}});	
		
		/* 查看详情 */
		$("#yzr-purchorder-more").linkbutton({onClick: function(){
			var rows = $("#tb-purchorder").datagrid("getSelections");
			if(rows.length == 1){
				$('#yzr-orderDet-window').window({'title': "查看订单详情"});
				$('#yzr-orderDet-window').window("open");
				var purchOrderId = rows[0].purchOrderId;
				$.getJSON("queryOrderById", {"orderId": purchOrderId}, function(data){
					$("#yzr-orderDet-ddbh").linkbutton({text: data.purchOrderId});
					$("#yzr-orderDet-jhbh").linkbutton({text: data.purchPurchId});
					$("#yzr-orderDet-cgr").linkbutton({text: data.staffName});
					$("#yzr-orderDet-dhsj").linkbutton({text: yzr_todate_purchOrder(data.purchOrderDate)});
					$("#yzr-orderDet-jhsj").linkbutton({text: yzr_todate_purchOrder(data.purchJiaohuoDate)});
					$("#yzr-orderDet-dhxs").linkbutton({text: data.purchOrderNumber});
					$("#yzr-orderDet-ddje").linkbutton({text: data.purchOrderMoney});
					$("#yzr-orderDet-yszt").linkbutton({text: data.purchYanshouState});
					/* $("#yzr-orderDet-ysjg").linkbutton({text: data.purchYanshouResult}); */
					$("#yzr-orderDet-rkzt").linkbutton({text: data.purchInstockState});
					
					
					if(data.purchYanshouState =='未验收'){
						$("#yzr-orderDet-yszt").css({'color': 'red'});
					}else{
						$("#yzr-orderDet-yszt").css({'color': 'green'});
					}
					/* if(data.purchYanshouResult=='不合格'){
						$("#yzr-orderDet-ysjg").css({'color': 'green'});
					} */
					
					if(data.purchInstockState =='未入库'){
						$("#yzr-orderDet-rkzt").css({'color': 'red'});
					}else{
						$("#yzr-orderDet-rkzt").css({'color': 'green'});
					}
				});	
				
				 //根据id查看详情	
				 $("#yzr-orderDet-dg").datagrid({
					url:'queryOrderByOrderId',
					width: '100%',
					queryParams:{
						page:1, 
		    			rows:100,
		    			orderId: purchOrderId
					}
				});
			}else{
				$.messager.alert("提示", "请选择一条记录!");
			}
		}});
		
		
		//日期转换
		function yzr_todate_purchOrder(value){
            var date = new Date(value);  
            return date.toLocaleDateString();
            
        }
		
		//查看计划明细-打印
		$("#yzr-purchorder-print").linkbutton({onClick: function(){
			var rows = $("#tb-purchorder").datagrid("getSelections");
			if(rows.length == 1){
				$('#yzr-orderDet-window').window({'title': "打印采购订单"});
				$('#yzr-orderDet-window').window("open");
				var purchOrderId = rows[0].purchOrderId;
				
				$.getJSON("queryOrderById", {"orderId": purchOrderId}, function(data){
					$("#yzr-orderDet-ddbh").linkbutton({text: data.purchOrderId});
					$("#yzr-orderDet-jhbh").linkbutton({text: data.purchPurchId});
					$("#yzr-orderDet-cgr").linkbutton({text: data.staffName});
					$("#yzr-orderDet-dhsj").linkbutton({text: yzr_todate_purchOrder(data.purchOrderDate)});
					$("#yzr-orderDet-jhsj").linkbutton({text: yzr_todate_purchOrder(data.purchJiaohuoDate)});
					$("#yzr-orderDet-dhxs").linkbutton({text: data.purchOrderNumber});
					$("#yzr-orderDet-ddje").linkbutton({text: data.purchOrderMoney});
					$("#yzr-orderDet-yszt").linkbutton({text: data.purchYanshouState});
					/* $("#yzr-orderDet-ysjg").linkbutton({text: data.purchYanshouResult}); */
					$("#yzr-orderDet-rkzt").linkbutton({text: data.purchInstockState});
					
					
					if(data.purchYanshouState=='未验收'){
						$("#yzr-orderDet-yszt").css({'color': 'red'});
					}
					if(data.purchInstockState=='未入库'){
						$("#yzr-orderDet-rkzt").css({'color': 'red'});
					}
				});	
				
				 //根据id查看详情	
				 $("#yzr-orderDet-dg").datagrid({
					url:'queryOrderByOrderId',
					width: '100%',
					queryParams:{
						page:1, 
		    			rows:100,
		    			orderId: purchOrderId
					}
				});
			}else{
				$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
			}
		}});
		
		//打印
		/* function printdivYzr(printpage){ 
			//获得当前页面body里面的内容
			var bodyHtml = document.body.innerHTML;
			//把打印的内容填充
			document.body.innerHTML = printpage; 
			//打印
			window.print(); 
			//把body的内容还原
			document.body.innerHTML = bodyHtml; 
			return true;

		} */
		
		//点击按钮打印
		/* $("#yzr-orderDet-print").linkbutton({
			onClick: function(){ */
				/* var printpage = $('#yzr-orderDet-printArea').html();
				printdivYzr(printpage); */
/* 				$("#yzr_orderDet_form").jqprint();
			}
		}); */
		
		//显示全部
		$("#yzr-purchorder-reload").linkbutton({onClick:function(){
			$("#tb-purchorder").datagrid({
	    		url: 'queryAllOrder', 
	    		method: 'get'
	    	});
		}});
		
		//模糊查询
		$('#yzr-purchorder-search').searchbox({
		    searcher:function(value,name){
		    	if(value == ''){
		    		$.messager.alert("提示", "请输入查询条件！");
		    	}else{
		    		$("#tb-purchorder").datagrid({	    		
			    		url:'queryByIf',
			    		method: 'post', 
			    		queryParams: {
			    			value: value,
			    			name: name
			    	}});
			    	$('#yzr-purchorder-search').searchbox('setValue', '');
		    	}		    	
		    }		    
		}); 
		
		//关闭编辑窗口，刷新
		$("#yzr-purchorder-closeWindow").linkbutton({onClick: function(){
			$(":hidden[x='y']").remove();			
			//重新加载采购计划
			$("#yzr-purch-cg").combogrid({
				 url:'queryStateAndAutState',
			}); 
			$('#yzr-purchorder-dg').datagrid('loadData',{total:0,rows:[]});				
			$('#yzr_purchorder_form').form("clear");				
			$('#yzr-purchorder-window').window('close');
			$("#tb-purchorder").datagrid("reload");
		}});
		
	});
</script>

	
	
	<!-- 显示所有采购订单 -->
	<table id="tb-purchorder" class="easyui-datagrid" 
		data-options="
			url:'queryAllOrder',
			singleSelect: true,
			fitColumns:true,
			fit:true,
			striped:true,
			pagination: true,
			pageSize: 16,
			pageList: [16, 32, 48, 54],
			rownumbers: true,
			toolbar: '#yzr-purchorder-toolbar',
			border:false
			">
		<thead>
			<tr>	
				<th data-options="field:'purchOrderId',width:'10%',checkbox:true,align:'center'">订单编号</th>				
				<th data-options="field:'purchPurchId',width:'17%',align:'center'">计划单号</th>
				<th data-options="field:'staffName',width:'10%',align:'center'">采购人</th>											
				<th data-options="field:'purchOrderDate',width:'13%',
									formatter:function(value){
					                          var date = new Date(value);  
					                          return date.toLocaleDateString();},align:'center'"
				>订货日期</th>				
				<th data-options="field:'purchJiaohuoDate',width:'13%',
									formatter:function(value){
					                          var date = new Date(value);  
					                          return date.toLocaleDateString();},align:'center'"
				>交货日期</th>
				<!-- <th data-options="field:'purchJiaohuoAddress',width:'12%',align:'center'">交货地点</th> -->
				<th data-options="field:'purchOrderNumber',width:'11%',align:'center'">订货项数</th>	
				<th data-options="field:'purchOrderMoney',width:'11%',align:'center'">订单金额</th>
				<th data-options="field:'purchYanshouState',width:'12%',align:'center',">验收状态</th>
				<th data-options="field:'purchInstockState',width:'12%',align:'center',
										styler: function(value,row,index){ 
	                                        if(row.purchInstockState == '已入库'){ 
	                                            return 'color:green;'; 
	                                        }else{
	                                        	return 'color:red;';
	                                        }}
	           ">是否入库</th>				
			</tr>
		</thead>
	</table>
	
	<!-- 工具栏 -->
	<div id="yzr-purchorder-toolbar">
		<a id="yzr-purchorder-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加订单</a>			
		<a id="yzr-purchorder-more" class="easyui-linkbutton" data-options="iconCls:'icon-more',plain:true">查看详情</a>
		<a id="yzr-purchorder-print" class="easyui-linkbutton" data-options="iconCls:'icon-print',plain:true">打印订单</a>				
		<a id="yzr-purchorder-reload" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>				
		<input id="yzr-purchorder-search" class="easyui-searchbox" data-options="menu: '#yzr-purchorder-pName', width: 250, prompt: '请输入关键字'"/>
	</div>
	
	<!-- 搜索栏 -->
	<div id="yzr-purchorder-pName" style="width:120px">
		<div data-options="name:'orderId'">订单编号</div>
	    <div data-options="name:'name'">采购人</div>
	    <div data-options="name:'checkState'">验收状态</div>
	    <div data-options="name:'rukuState'">是否入库</div>
	</div>
	
	
	<!--查看订单详情窗口-打印 -->
	<div id="yzr-orderDet-window" class="easyui-window" title="打印订单详情" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:70%;height:70%;">		
		<div class="easyui-layout" style="padding:0px;" data-options="fit:true">			
			<div id="yzr-orderDet-printArea" data-options="region:'center'" style="padding:5px;border-top:none;border-left:none;border-right:none;">			
				<form id="yzr_orderDet_form" method="post">
					<table width="100%">
						<tr>						
							<td>订单编号:<a id="yzr-orderDet-ddbh" name="purchOrderId" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>订货项数:<a id="yzr-orderDet-dhxs" name="purchOrderNumber" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>采购人:<a id="yzr-orderDet-cgr" name="staffName" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>订货时间:<a id="yzr-orderDet-dhsj" name="purchOrderDate" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>交货时间:<a id="yzr-orderDet-jhsj" name="purchJiaohuoDate" class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
						<tr>	
							<td>计划编号:<a id="yzr-orderDet-jhbh" name="purchPurchId" class="easyui-linkbutton" data-options="plain:true"></a></td>													
							<td>订单金额:<a id="yzr-orderDet-ddje" name="purchOrderMoney" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>验收状态:<a id="yzr-orderDet-yszt" name="purchYanshouState" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<!-- <td>验收结果:<a id="yzr-orderDet-ysjg" name="purchYanshouResult" class="easyui-linkbutton" data-options="plain:true"></a></td> -->
							<td>入库状态:<a id="yzr-orderDet-rkzt" name="purchInstockState" class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
					</table>
						
					<div style="margin: 5px;">
						<div id="yzr-orderDet-tabs" class="easyui-tabs" style="width:100%; margin-top:10px;" 
							data-options="plain:true,narrow:true">
							
							<div title="采购订单明细" style="padding:10px;">
								<table id="yzr-orderDet-dg" class="easyui-datagrid" 
										data-options="
											iconCls: 'icon-edit',
											singleSelect: true,										
											width: '100%'
											">
										<thead>
											<tr>	
												<th data-options="field:'purchOrderDetId',width:'18%',align:'center'">订单明细编号</th>			
												<th data-options="field:'orderDetMedName',width:'18%',align:'center'">药品名称</th>
												<th data-options="field:'orderDetGuige',width:'8%',align:'center'">规格</th>
												<th data-options="field:'orderDetMedUnit',width:'8%',align:'center'">单位</th>
												<th data-options="field:'orderDetPrice',width:'10%',align:'center'">单价</th>
												<th data-options="field:'orderDetNumber',width:'9%',align:'center'">数量</th>
												<th data-options="field:'orderDetMoney',width:'9%',
																	styler:function(value,row,index){ 
																		if(row.orderDetMoney <= 0){
																			return 'color:red;';
																		}},align:'center'">金额</th>
												<th data-options="field:'supName',width:'20%',align:'center'">供应商</th>
											</tr>
										</thead>
								 </table>
							</div>							
						</div>						
					</div>
				</form>				
			</div>
			
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="yzr-orderDet-print" class="easyui-linkbutton" data-options="iconCls:'icon-print', plain:true">打印</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:$('#yzr-orderDet-window').window('close');" onclick="">取消</a>
			</div>			
		</div>
	</div>
		
	
	<!-- 添加采购订单 -->
	<div id="yzr-purchorder-window" class="easyui-window" title="新增采购订单" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:70%;height:70%;">		
		<div class="easyui-layout" style="padding:0px;" data-options="fit:true">			
			<div data-options="region:'center'" style="padding:5px;border-top:none;border-left:none;border-right:none;">			
				<form id="yzr_purchorder_form" action="addPurchOrder" method="post">
					<table width="98%" style="margin-left:10px;">
						<tr>
							<td width="60%">				
								<select id="yzr-purch-cg" class="easyui-combogrid" name="purchOrder.purchPurchId"
									data-options="
										label: '采购计划单',
										required:true,
										width: '60%',
										panelWidth: '295',
										panelHeight: 'auto',
										url: 'queryStateAndAutState',
										pagination: true,
										pageSize: 8,
										pageList: [8, 16, 24, 32],
										idField: 'purchId',
										textField: 'purchId',
										columns: [[
											{field:'purchId',title:'计划单号',width:120},
											{field:'purchTitle',title:'名称',width:110},
											{field:'purchState',title:'采购状态',width:60}
										]]
									"></select>
							</td>
							<td  width="60%">
								<select class="easyui-combogrid" name="purchOrder.purchPeople" id="yzrr-purchoder-cgr"
									data-options="
										label: '采购人',
										readonly:true,
										required:true,
										width: '80%',
										panelWidth: '290',
										panelHeight: 'auto',
										url: 'queryAllStaff',
										pagination: true,
										pageSize: 8,
										pageList: [8, 16, 24, 32],
										idField: 'staffNo',
										textField: 'staffName',
										columns: [[
											{field:'staffName',title:'姓名',width:100},
											{field:'departmentName',title:'部门',width:100},
											{field:'postName',title:'职务',width:85}
										]]
									"></select>
							</td>
						</tr>
						<tr>
							<td>
								<input class="easyui-datebox" name="purchOrder.purchOrderDate"
									data-options="required:true,label:'订货日期',width:'60%'">
							</td>
							<td>
								<input class="easyui-datebox" name="purchOrder.purchJiaohuoDate"
									data-options="required:true,label:'交货日期',width:'80%'">
							</td>
						</tr>
					</table>
				
			
					<div style="margin: 5px;">
						<div id="yzr-purchorder-tabs" class="easyui-tabs" style="width:98%; margin-top:10px;" data-options="plain:true,narrow:true">				
							<div title="采购订单明细" style="padding:10px">
								<table id="yzr-purchorder-dg" class="easyui-datagrid" style="height:auto;"
										data-options="
											iconCls: 'icon-edit',
											singleSelect: true,
											toolbar: '#yzr-purchorder-tb',
											method: 'get',
											onClickCell: onClickCellYzr_order,
											onEndEdit:onEndEditYzr_order,
											width: '100%'
										">
									<thead>
										<tr>
										<!-- orderDetMedId,orderDetGuiGe,orderDetNumber,orderDetSupId,orderDetUnit -->
										<!-- 	purchDetMedId，purchDetGuige，purchDetNumber，purchDetSupId，purchDetUnit -->
										<!-- purchDetId,purchDetGuige,purchDetMedId,purchDetNumber,purchDetPurchId,purchDetSupId,purchDetUnit,
										purchDetYijiMoney,medId,medName,supId,supName -->			
											<th data-options="field:'orderDetMedName',width:'10%',editor:'textbox',hidden:true">药品名</th>											
											<th data-options="field:'purchDetMedId',width:'20%',align:'center',
														formatter:function(value,row){
															return row.medName;
														},
														editor:{
															type:'combogrid',
															options:{
																required:true,
																url: 'queryAllMedicine',
																pagination: true,
																pageSize: 8,
																pageList: [8, 16, 24, 32],
																idField: 'medId',
																textField: 'medName',
																panelWidth: '290',
																panelHeight: 'auto',
																columns: [[
																	{field:'medId',title:'药品编号',width:120},
																	{field:'medName',title:'药品名称',width:105},
																	{field:'medKind',title:'类型',width:60}
																]]										
															}
												}">药品名称</th>
											<th data-options="field:'orderDetBatchnumber',width:'15%',align:'center',editor:{type:'textbox',options:{required:true,validType: ['pihao']}}">批号</th>
											<th data-options="field:'purchDetGuige',width:'10%',align:'center',editor:{type:'textbox',options:{required:true}}">规格</th>
											<th data-options="field:'purchDetUnit',width:'9%',align:'center',editor:{
													type: 'combobox',
													options:{
														required:true,
														valueField: 'label',
														textField: 'value',
														panelHeight: 'auto',
														data: [{label:'箱',value:'箱'},
																{label:'盒',value:'盒'},
																{label:'瓶',value:'瓶'},
																{label:'袋',value:'袋'},
																{label:'片',value:'片'},
																{label:'支',value:'支'},
																{label:'板',value:'板'}
															]
													}
												}">单位</th>
											<th data-options="field:'orderDetPrice',width:'9%',align:'center',editor:{type:'numberbox',options:{required:true,precision:2}}">单价</th>
											<th data-options="field:'purchDetNumber',width:'9%',align:'center',editor:{type:'numberbox',options:{}}">数量</th>
											<th data-options="field:'orderDetMoney',width:'9%',align:'center',editor:{type:'numberbox',options:{precision:2,disabled:true}}">金额</th>
											
											<th data-options="field:'supId',width:'20%',align:'center',
												formatter:function(value,row){
													return row.supName;
												},
												editor:{
													type: 'combogrid',								
													options:{
														url: 'queryAllSupplier',
														required:true,
														pagination: true,
														pageSize: 8,
														pageList: [8, 16, 24, 32],
														idField: 'supId',
														textField: 'supName',
														panelWidth: '290',
														panelHeight: 'auto',
														columns: [[
															{field:'supId',title:'供应商编号',width:120},
															{field:'supName',title:'供应商名称',width:105},
															{field:'supKind',title:'类型',width:60}
														]]										
												}
											}">供应商</th>
										</tr>
									</thead>							
								</table>
								
								<!-- 工具栏 -->
								<div id="yzr-purchorder-tb" style="height:auto">
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendYzr_order()">添加一行</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeitYzr_order()">移除一行</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" onclick="acceptYzr_order()">应用</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="rejectYzr_order()">撤销</a>
								</div>
							</div>
							
						</div>			
					</div>
				</form>
			</div>
					
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save', onClick: savePlanYzr_order">保存订单</a>
				<a id="yzr-purchorder-closeWindow" class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true">取消</a>
			</div>			
		</div>
	</div>
 
</body>
</html>